﻿using System;
using System.Web.UI;

using BizElements.BusinessLayer;

namespace BizElements.Web
{
    /// <summary>
    /// Control bound to a business object field (see: <see cref="IBindableField"/>).
    /// </summary>
    /// <remarks>In addition to just being bound to a specified property, bound control also handles how errors
    /// associated with the property are displayed.</remarks>
    public interface IBoundControl
    {
        /// <summary>
        /// Specifies mode the control is exercising when accessing data stored in business objects. 
        /// </summary>
        /// <remarks><p>Default value should be <see cref="FieldAccessMode.Automatic"/>, i.e. control should
        /// check the <see cref="IValueObject.IsReadOnly"/> property to determine the access mode.</p>
        /// <p>Data may not be changed in read-only mode. Sometimes this means that the control
        /// will be rendered differently. Eg. lookup controls should hide buttons.</p></remarks>
        FieldAccessMode AccessMode { get; set; }

        /// <summary>Name of the control property which is bound two-way to a business object field.</summary>
        string TwoWayBoundProperty { get; }

        /// <summary>Names of additional control properties which are bound one-way to business object properties.</summary>
        string[] OneWayBoundProperties { get; }

        /// <summary>Optional error label control which displays errors associated with the given field.</summary>
        ITextControl ErrorLabel { get; }

        /// <summary>Optional caption label control which contains field's caption/title.</summary>
        ITextControl CaptionLabel { get; }

        /// <summary>Optional control which contains additional control info.</summary>
        ITextControl TooltipLabel { get; }

        /// <summary>Optional control that indicates whether a field is required. May be a picture control, a label control with asterisk etc.</summary>
        Control RequiredFieldIndicatorControl { get; }
    }
}